from .PageElement import PageElement, POLL_FREQUENCY
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

from .Selector import Selector


class WaitElement(PageElement):

    def wait_element_ready(self, timeout=None, poll_frequency = POLL_FREQUENCY, recheck = True):
        timeout = timeout or self._wait_time_out
        WebDriverWait(self._driver, timeout, poll_frequency).until(EC.visibility_of_element_located((Selector.MAP[self._selector_type], self._selector_str)))
